-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(fixer): add Prowler Fixer feature! #3634
Conversation
prowler/lib/check/check.py
Outdated
@@ -419,12 +419,33 @@ def run_check(check: Check, output_options) -> list: | |||
return findings | |||
|
|||
|
|||
def run_fixer(check_findings, check_name, c): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is c
? Please use a more readable word, is free of cost!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -410,6 +410,18 @@ def __get_ebs_encryption_settings__(self, regional_client): | |||
f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" | |||
) | |||
|
|||
def __enable_ebs_encryption_by_default__(self, region): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test for this in the service. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## prowler-4.0-dev #3634 +/- ##
===================================================
- Coverage 86.08% 85.88% -0.21%
===================================================
Files 705 719 +14
Lines 21868 22332 +464
===================================================
+ Hits 18826 19179 +353
- Misses 3042 3153 +111 ☔ View full report in Codecov by Sentry. |
prowler/lib/check/check.py
Outdated
Run the fixer for the check if it exists and there are any FAIL findings | ||
Args: | ||
check_findings (list): list of findings | ||
check_name (str): check name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don't need the check name here, you can use check.CheckID
.
@@ -544,3 +544,19 @@ def test__describe_volumes__(self): | |||
assert ec2.volumes[0].tags == [ | |||
{"Key": "test", "Value": "test"}, | |||
] | |||
|
|||
# Test EC2 EBS Enabling Encryption by Default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lovely!
@@ -15,7 +15,7 @@ def print_banner(args): | |||
""" | |||
print(banner) | |||
|
|||
if args.verbose: | |||
if args.verbose or getattr(args, "fix", None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this needs to be done force the verbose
to be True
if the fix
is set, I think is more than enough to have one argument to control the outputs.
Description
Add Prowler Fixer feature to fix checks when Prowler finds misconfigurations. At the moment, it is only included for check
ec2_ebs_default_encryption
.prowler aws -c ec2_ebs_default_encryption --fixer
prowler aws --list-fixer
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.